#include "stdafx.h"
#include <toftlib/net/telnet/TelnetClient.hpp>
#include <iostream>

using namespace toftlib;
using namespace boost;
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
    try
    {
        TelnetClient<512> client;
        //client.Connect("192.168.1.100", 23);
        client.Connect("132.5.1.45", 23);
        //client.Connect("167.76.40.43", 23);
        shared_ptr<char> response;



        cout << client.ReadUntil("Username: ") << endl;
        //cout << client.ReadUntil("Account Name: ") << endl;

        client.SendData("shawn_hu\r");
        //client.SendData("bridge\r");

        cout << client.ReadUntil("Password: ") << endl;

        client.SendData("Myopenvms2\r");
        //client.SendData("data\r");

        cout << client.ReadUntil("RE4_Shawn Hu> ") << endl;
        //cout << client.ReadUntil("Mode: ") << endl;
        //client.SendData("\r");

        //cout << client.ReadUntil(":\\]") << endl;
        client.SendData("dir\r");

        cout << client.ReadUntil("RE4_Shawn Hu> ") << endl;
        //cout << client.ReadUntil(":\\]") << endl;

        client.Disconnect();
    }
    catch (boost::exception& ex)
    {
        cout << diagnostic_information(ex) << endl;

    }
    catch (std::exception& ex)
    {
        cout << ex.what() << endl;
    }
    catch (...)
    {
        cout << "Exception!!!" << endl;
    }

	return 0;
}

